package com.hitqz.robot.camera;

import cn.hutool.system.SystemUtil;
import com.hitqz.robot.api.business.enums.BrandEnum;
import com.hitqz.robot.camera.common.Constant;
import com.hitqz.robot.camera.lib.callback.fCaptureReceiveCB;
import com.hitqz.robot.camera.module.CapturePictureModule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Service;

import javax.security.auth.spi.LoginModule;

/**
 * @author kehanjiang
 * @date 2024/08/15
 */
@Service("DhCameraService")
@Slf4j
public class DhCameraService implements IEquipmentService, CommandLineRunner {

    @Override
    public BrandEnum brand() {
        return BrandEnum.DH;
    }

    @Override
    public boolean intSdk() {
        LoginModule.init();
        if (Constant.m_CaptureReceiveCB == null) {
            Constant.m_CaptureReceiveCB = new fCaptureReceiveCB();
        }
        CapturePictureModule.setSnapRevCallBack(Constant.m_CaptureReceiveCB);
        return false;
    }

    @Override
    public void run(String... args) throws Exception {
        //jna崩溃改为抛异常
        if (SystemUtil.getOsInfo().isWindows()) {
            System.setProperty("jna.protected", "true");
        }
        log.info("os.name:{},os.version:{}", System.getProperty("os.name"), System.getProperty("os.version"));
    }
}